package main

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"log"
	"time"
)

type GormUser struct {
	ID       uint
	Phone    string
	Name     string
	Password string
}

func main() {
	db, err := gorm.Open(mysql.Open("root:root@tcp(192.168.179.22:3306)/beego?parseTime=true&loc=Asia%2FShanghai"), &gorm.Config{})
	if err != nil {
		log.Fatal(err)
	}
	sqlDb, _ := db.DB()
	sqlDb.SetMaxOpenConns(5)
	sqlDb.SetMaxIdleConns(2)
	sqlDb.SetConnMaxIdleTime(time.Minute)

	//user := GormUser{
	//	Phone:    "133432423424",
	//	Name:     "shenzhen1",
	//	Password: "6666",
	//}
	//
	//db.Save(&user) //保存数据
	//db.Create(&user) //方法用于插入数据

	//删除数据
	var GormUser = new(GormUser)
	db.Where("id = ?", 1).Delete(&GormUser)
}
